class Recipe < ActiveRecord::Base
  has_many :media, :as => :rmedia
  has_many :ingredient, :dependent=>:destroy
  has_many :comments, :dependent=>:destroy
  has_many :ratings, :dependent=>:destroy
  has_many :cookbook_recipe, :dependent=>:destroy

  validates_presence_of(:title, :category, :directions, :description)

  def add_new_ingredient()
    @count = 0
    self.ingredient.each {
      @count = @count + 1
    }
    @newing = Ingredient.new()
    @newing.name = "Ingredient#{@count}"
    
    self.ingredient << @newing
    @newing
  end

end
